package com.feihong.txgw.tx_precenter;

import com.feihong.txgw.inter.contract.adr.IDeliveryAdrEditContract;
import com.feihong.txgw.model.base_bean.BaseResponse;
import com.feihong.txgw.model.bean.deliveryAdr.DeliveryAdrEntity;
import com.feihong.txgw.tx_model.EditDeliveryAdrMainModel;

import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;

/**
 * @Author wangziheng
 * @ProjectName txgw_app
 * @ClassName EditDeliveryAdrMainPrecenter
 * @package com.feihong.txgw.tx_precenter
 * @data 2018/5/7 19:48
 * @Describe
 * @Change
 */
public class EditDeliveryAdrMainPrecenter extends IDeliveryAdrEditContract.AbDeliveryAdrEditMainPrecenter{
    @Override
    public void editAdr(String adrInfo,DeliveryAdrEntity deliveryAdrEntity) {
        mIModel.editAdr(deliveryAdrEntity,adrInfo).subscribe(new Observer<BaseResponse>() {
            @Override
            public void onSubscribe(Disposable d) {
                mRxManager.register(d);
            }

            @Override
            public void onNext(BaseResponse result) {
                mIView.editAdrResult(result);
            }

            @Override
            public void onError(Throwable e) {
                mIView.loadDataError();
            }

            @Override
            public void onComplete() {

            }
        });
    }

    @Override
    public IDeliveryAdrEditContract.IDeliveryAdrEditMainModel getModel() {
        return EditDeliveryAdrMainModel.create();
    }

    @Override
    public void onStart() {

    }

    public static EditDeliveryAdrMainPrecenter create(){
        return new EditDeliveryAdrMainPrecenter();
    }
}
